/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.server.modules.sys.entity.account;

import com.fasterxml.jackson.annotation.JsonBackReference;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;

import com.server.common.persistence.TreeEntity;

/**
 * 会计科目管理Entity
 * @author 王磊
 * @version 2016-09-14
 */
public class Account extends TreeEntity<Account> {
	
	private static final long serialVersionUID = 1L;
	protected Account parent;		// 上级
	protected String parentIds;		// parent_ids
	protected String name;		// 科目名称
	protected String number;		// 科目编码
	protected String reamrks;		// 备注
	
	public Account() {
		super();
	}

	public Account(String id){
		super(id);
	}

	@JsonBackReference
	@NotNull(message="上级不能为空")
	public Account getParent() {
		return parent;
	}

	public void setParent(Account parent) {
		this.parent = parent;
	}
	
	@Length(min=1, max=2000, message="parent_ids长度必须介于 1 和 2000 之间")
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}
	
	@Length(min=1, max=255, message="科目名称长度必须介于 1 和 255 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Length(min=1, max=15, message="科目编码长度必须介于 1 和 15 之间")
	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	
	@Length(min=1, max=255, message="备注长度必须介于 1 和 255 之间")
	public String getReamrks() {
		return reamrks;
	}

	public void setReamrks(String reamrks) {
		this.reamrks = reamrks;
	}
	
	public String getParentId() {
		return parent != null && parent.getId() != null ? parent.getId() : "0";
	}
}